package com.yeedingtong.config;

import java.util.HashMap;
import java.util.Map;

import cn.kivensoft.util.ConfigureFactory;
import cn.kivensoft.util.Fmt;
import jdbm.helper.FastIterator;

public class Main {

	Map<String, String> data = new HashMap<>();
	
	public static void main(String[] args) {
		Configure conf = Configure.instance();
		loadConfigure(conf);
		conf.setJdbmFile(ConfigureFactory.getRootPath(Main.class) + conf.getJdbmFile());
		Jdbm jdbm = Jdbm.instance();
		jdbm.open(conf);
		
		
		/*
		for(int i = 0; i < 10; i++) {
			jdbm.put(Fmt.fmt("key_{}", i), Fmt.fmt("value is {}", i * 3));
		}
		FastIterator<String> iter = jdbm.keys();
		String key;
		while ((key = iter.next()) != null) {
			Fmt.pl("key = {}, value = {}", key, jdbm.get(key));
		}
		*/
		
	}

	private static void loadConfigure(Configure initValue) {
		String pName = Main.class.getName();
		pName = pName.substring(0, pName.lastIndexOf('.'));
		ConfigureFactory.get(pName + ".properties", Main.class, initValue);
	}
	
}
